<template>
    <div>
      <h1>Login/Register</h1>
      <form @submit.prevent="registerUser">
        <input v-model="user.name" placeholder="Name" required />
        <input v-model="user.email" type="email" placeholder="Email" required />
        <input v-model="user.password" type="password" placeholder="Password" required />
        <button type="submit">Register</button>
      </form>
    </div>
  </template>
  
  <script>
  import axios from 'axios';
  
  export default {
    data() {
      return {
        user: {
          name: '',
          email: '',
          password: '',
        },
      };
    },
    methods: {
      async registerUser() {
        try {
          await axios.post('http://localhost:8082/api/v1/auth/register', this.user,{
            headers: {
              'Content-Type': 'application/json',
            },
          });
          alert('Registration successful');
        } catch (error) {
          console.error('Error registering user:', error);
        }
      },
    },
  };
  </script>
  
  <style scoped>
  /* 样式可以根据需要添加 */
  </style>
  